using ASP;
using HoWave.Common;
using HoWave.Web;
using HoWave.Web.Admin;
using System;
using System.Collections;
using System.Data;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.WebControls;
public class HL_Admin_Admin_UserExpRecorde : Admin, IRequiresSessionState
{
	protected TextBox TxtUserName;
	protected DropDownList Dropincome_output;
	protected TextBox TxtBeginDate;
	protected TextBox TxtEndDate;
	protected Button but;
	protected GridView GridView1;
	protected Button Button1;
	protected Label PagePanel;
	private Pagination _pagehander;
	private string wherestr = "";
	private string orderbystr = "";
	private string linkhead = "";
	private bool tag = true;
	private ArrayList al = new ArrayList();
	private IDbDataParameter[] param;
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected Pagination m_pagehander
	{
		get
		{
			Pagination pagehander;
			if (this._pagehander == null)
			{
				this._pagehander = new Pagination();
				this._pagehander.SQL_LeftJoinTable = "HL_User";
				this._pagehander.SQL_LeftJoinField = "UserName";
				this._pagehander.SQL_JoinField2 = "UserID";
				this._pagehander.SQL_JoinField = "UserID";
				this._pagehander.P_Object = "记录";
				pagehander = this._pagehander;
			}
			else
			{
				pagehander = this._pagehander;
			}
			return pagehander;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!base.IsPostBack)
		{
			this.BindList();
		}
		this.TxtBeginDate.Attributes.Add("onClick", string.Concat(new string[]
		{
			"show_cele_date(",
			this.TxtBeginDate.UniqueID,
			",'','',",
			this.TxtBeginDate.UniqueID,
			");"
		}));
		this.TxtEndDate.Attributes.Add("onClick", string.Concat(new string[]
		{
			"show_cele_date(",
			this.TxtEndDate.UniqueID,
			",'','',",
			this.TxtEndDate.UniqueID,
			");"
		}));
	}
	protected void BindList()
	{
		this.QueryString();
		int num = Fetch.GetID("page");
		if (num == 0)
		{
			num = 1;
		}
		int pageSize = this.GridView1.PageSize;
		if (this.al.Count > 0)
		{
			this.param = new IDbDataParameter[this.al.Count];
			this.al.CopyTo(this.param, 0);
		}
		if (this.param != null)
		{
			this.GridView1.DataSource = this.m_pagehander.GetDataTable("HL_UserExpRecorde", num, pageSize, "ID", this.wherestr, this.orderbystr, this.conn, this.param);
		}
		else
		{
			this.GridView1.DataSource = this.m_pagehander.GetDataTable("HL_UserExpRecorde", num, pageSize, "ID", this.wherestr, this.orderbystr, this.conn, null);
		}
		this.GridView1.DataBind();
		this.m_pagehander.P_LinkHead = this.linkhead;
		this.PagePanel.Text = this.m_pagehander.ShowPagePanel();
	}
	protected void QueryString()
	{
		string text = Fetch.Get("un");
		if (text != string.Empty && this.tag)
		{
			this.TxtUserName.Text = text;
		}
		else
		{
			text = this.TxtUserName.Text;
		}
		if (text != string.Empty)
		{
			this.wherestr += "and HL_UserExpRecorde.UserID in (Select UserID From [HL_User] Where UserName like '%'+ @UserName +'%') ";
			this.al.Add(this.conn.CreateParameter("@UserName", DbType.String, text));
			this.linkhead = this.linkhead + "&un=" + base.Server.UrlEncode(text);
		}
		string text2 = Fetch.Get("type");
		if (text2 != string.Empty && this.tag)
		{
			this.Dropincome_output.Text = text2;
		}
		else
		{
			text2 = this.Dropincome_output.SelectedValue;
		}
		if (text2 != string.Empty)
		{
			this.wherestr = this.wherestr + "and HL_UserExpRecorde.cType=" + text2 + " ";
			this.linkhead = this.linkhead + "&type=" + text2;
		}
		string text3 = Fetch.Get("bt");
		string text4 = Fetch.Get("et");
		if (text3 != string.Empty && this.tag)
		{
			this.TxtBeginDate.Text = text3;
		}
		else
		{
			text3 = this.TxtBeginDate.Text;
		}
		if (text4 != string.Empty && this.tag)
		{
			this.TxtEndDate.Text = text4;
		}
		else
		{
			text4 = this.TxtEndDate.Text;
		}
		if (text3 != string.Empty)
		{
			if (text4 != string.Empty)
			{
				if (Convert.ToDateTime(text4) < Convert.ToDateTime(text3))
				{
					this.WriteErrMsg("", Language.Get("Common/DateTimeErr"), "");
				}
			}
			this.wherestr += "and DateDiff(d, CreateTime, @BeginDate)<=0 ";
			this.al.Add(this.conn.CreateParameter("@BeginDate", DbType.DateTime, text3));
			this.linkhead = this.linkhead + "&bt=" + text3;
		}
		if (text4 != string.Empty)
		{
			this.wherestr += "and DateDiff(d, CreateTime, @EndDate)>=0 ";
			this.al.Add(this.conn.CreateParameter("@EndDate", DbType.DateTime, text4));
			this.linkhead = this.linkhead + "&et=" + text4;
		}
		if (this.wherestr != "")
		{
			this.wherestr = "and" + this.wherestr;
			this.wherestr = this.wherestr.Replace("andand", "where");
		}
	}
	protected void OnSearch(object sender, EventArgs e)
	{
		this.tag = false;
		this.BindList();
	}
	protected void DeleteOne(object sender, CommandEventArgs e)
	{
		int num = Convert.ToInt32(e.CommandArgument);
		if (num > 0)
		{
			UserExpRecordeBll userExpRecordeBll = new UserExpRecordeBll(this.conn);
			userExpRecordeBll.DeleteRecordeByID(num);
			this.BindList();
		}
	}
	protected void DeleteAll(object sender, EventArgs e)
	{
		string text = Fetch.Post("IDS");
		if (Text.CheckNumList(text, ','))
		{
			UserExpRecordeBll userExpRecordeBll = new UserExpRecordeBll(this.conn);
			userExpRecordeBll.DeleteRecorde(text);
			this.BindList();
		}
	}
	protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#E7EDFE'");
		e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
	}
}
